unit App.Imp.TAppClassTableLoaderImp;

interface

uses SmallStruct.Core,
  SmallStruct.BusinessObject.TSSAdvancedBusinessObject,
  Sysutils;

type
  TAppClassTableLoaderImp = class(TSSAdvancedBusinessObject, ISSClassTableLoader)
  public
    procedure LoadClassTable(AClassTable: ISSClassTable);
  end;

implementation

uses
  SmallStruct.Database,
  SmallStruct.Core.TSSClassTable,
  SmallStruct.Model.TSSADODataModel,
  SmallStruct.Model.TSSDynamicModel,
  SmallStruct.View.TSSDataGridView,
  SmallStruct.View.TSSDataFormView,
  SmallStruct.View.TSSChartView;

const
  S_OBJECT_TABLE = 'S5_OBJECT_V';

  { TAppClassTableLoaderImp }

procedure TAppClassTableLoaderImp.LoadClassTable(AClassTable: ISSClassTable);
var
  Q: ISSDataSet;
begin
  Q := Query('SELECT * FROM ' + S_OBJECT_TABLE);

  try
    while not Q.IsEof do
    begin
      if Q.GetStringValue('OBJECT_TYPE') = 'DATA_MODEL' then
        AClassTable.RegisterClass(Q.GetStringValue('OBJECT_NAME'), TSSADODataModel)
      else if Q.GetStringValue('OBJECT_TYPE') = 'DYNAMIC_MODEL' then
        AClassTable.RegisterClass(Q.GetStringValue('OBJECT_NAME'), TSSDynamicModel)
      else if Q.GetStringValue('OBJECT_TYPE') = 'DATA_GRID_VIEW' then
        AClassTable.RegisterClass(Q.GetStringValue('OBJECT_NAME'), TSSDataGridView)
      else if Q.GetStringValue('OBJECT_TYPE') = 'DATA_FORM_VIEW' then
        AClassTable.RegisterClass(Q.GetStringValue('OBJECT_NAME'), TSSDataFormView)
      else if Q.GetStringValue('OBJECT_TYPE') = 'BAR_CHART_VIEW' then
        AClassTable.RegisterClass(Q.GetStringValue('OBJECT_NAME'), TSSChartView)
      else if Q.GetStringValue('OBJECT_TYPE') = 'PIE_CHART_VIEW' then
        AClassTable.RegisterClass(Q.GetStringValue('OBJECT_NAME'), TSSChartView)
      else if Q.GetStringValue('OBJECT_TYPE') = 'FAST_LINE_CHART_VIEW' then
        AClassTable.RegisterClass(Q.GetStringValue('OBJECT_NAME'), TSSChartView)
      else if Q.GetStringValue('OBJECT_TYPE') = 'POINT_CHART_VIEW' then
        AClassTable.RegisterClass(Q.GetStringValue('OBJECT_NAME'), TSSChartView);

      Q.Next;
    end;
  finally
    Q.ReleaseObjectInstance;
    Q := nil;
  end;
end;

end.
